//import Vue from 'vue'
import Vue from 'vue/dist/vue.esm.js'
import App from './App.vue'
import VueRouter from 'vue-router'
import Vuex from 'vuex'

import '@/assets/app.css'
import routes from './routes.js'
  
//import home from './home/home.vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI);



Vue.config.productionTip = false

Vue.use(VueRouter)
Vue.use(Vuex)
//Vue.component("Timer", Timer);
//Vue.component("Timer10", Timer10);

Vue.prototype.delayRun = function(fn, delayMilliseconds){
	return window.setTimeout(fn, delayMilliseconds);
}

Vue.prototype.cancleRun = function(delayRunId){
	window.clearTimeout(delayRunId);
}
  
const router = new VueRouter({
	mode:'hash',
	routes // (缩写) 相当于 routes: routes
})

const store = new Vuex.Store({
  state: {
    menuIndex: 1
  },
  mutations: {
    setMenuIndex (state, index) {
      state.menuIndex = index;
    }
  }
})
 
new Vue({
	render: h => h(App),
	router,
	store,
}).$mount('#app')


Vue.prototype.toast = function(msg, milliseconds){
	window.App.toast(msg, milliseconds);
}

//全局守卫 
router.beforeEach((to, from, next)=> {
	window.App.toast('');
	next();
})
 

